<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script src="../js/jquery-1.11.3.js"></script>
    <script src="../js/jquery-3.2.1.js"></script>
</head>
<body>
<div>
    <h4>用户登录</h4>
    <form id="login_form">
        <div>用户名：<input type="text" name="username"></div><br/>
        <div>密码：<input type="password" name="password"></div><br/>
        <div>
            <input id="btn_login" type="button" value="登录"/>
        </div>
    </form>
</div>
<script type="text/javascript">
    $("#btn_login").click(function () {
        var url = "../user/handle_login.do";
        var data = $("#login_form").serialize();
        console.log("提交数据： " + data);
        $.ajax({
            "url":url,
            "data": data,
            "type":"POST",
            "dataType":"json",
            "success":function (json) {
                if (json.state == 200){
                    alert("登录成功！");
                }else {
                    alert(json.message);
                }
            }
        });
    });
</script>
</body>
</html>